<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/7/12
 * Time: 11:28
 */

namespace app\admin\model;


class GoldDisplay extends DataBase
{

    public function boxGift($gold_egg_id)
    {
        $page_config = array(
            'page' => input('offset', 1),
            'list_rows' => input('limit', 10),
        );
        $data = $this->where('gold_egg_id',$gold_egg_id)->paginate($page_config);
        foreach($data as $key => $value){
            if($value['type'] == 1){
                $giftInfo = Gift::where('id',$value['prize_id'])->find();
                $data[$key]['dec'] = '暂无';
            }
            else{
                $giftInfo = Prop::field('prop_name as gift_name,prop_pic as gift_url,dec')->where('id',$value['prize_id'])->find();
                $data[$key]['dec'] = $giftInfo['dec'];
            }
            $data[$key]['gift_name'] = $giftInfo['gift_name'];
            $data[$key]['gift_url'] = $giftInfo['gift_url'];
            $data[$key]['rate'] =  $value['rate'] .'%';
        }
        return $data;
    }
}